!rm -f wavenet_vocoder/*.pickle
!scp -i ~/.ssh/no_passphrase_rsa peterpaullake@35.202.127.142:/home/peterpaullake/wavenet-features-private/wavenet_vocoder/*.pickle wavenet_vocoder/
1605539161.pickle 100% 86KB 457.2KB/s 00:00 1605541133.pickle 100% 86KB 904.1KB/s 00:00 1605541831.pickle 100% 221KB 2.2MB/s 00:00 1605545530.pickle 100% 344KB 3.4MB/s 00:00 1605547400.pickle 100% 344KB 6.1MB/s 00:00 1605549469.pickle 100% 344KB 6.3MB/s 00:00 1605549473.pickle 100% 221KB 4.1MB/s 00:00 1605549634.pickle 100% 221KB 4.1MB/s 00:00 1605552125.pickle 100% 344KB 5.4MB/s 00:00 1605556098.pickle 100% 221KB 3.7MB/s 00:00 1605558635.pickle 100% 344KB 6.3MB/s 00:00 1605562288.pickle 100% 221KB 4.1MB/s 00:00 1605564722.pickle 100% 344KB 5.9MB/s 00:00 1605568699.pickle 100% 344KB 5.9MB/s 00:00 1605572373.pickle 100% 221KB 4.1MB/s 00:00 1605574725.pickle 100% 221KB 4.1MB/s 00:00 1605577238.pickle 100% 344KB 6.3MB/s 00:00 1605581138.pickle 100% 221KB 3.9MB/s 00:00 1605583637.pickle 100% 221KB 3.8MB/s 00:00 1605585991.pickle 100% 221KB 4.1MB/s 00:00 1605588493.pickle 100% 344KB 6.0MB/s 00:00 1605592159.pickle 100% 221KB 4.1MB/s 00:00 1605594665.pickle 100% 221KB 4.1MB/s 00:00 1605597155.pickle 100% 221KB 3.7MB/s 00:00 1605599693.pickle 100% 344KB 5.9MB/s 00:00
%load_ext autoreload
%autoreload 1
import datetime
from IPython.display import Audio, Image, display
import librosa.display
import matplotlib.pyplot as plt
import numpy as np
import os
import pickle
%aimport wavenet_features
wf = wavenet_features
SAMPLE_RATE = wf.hparams.hparams.sample_rate
os.chdir('/home/peter/wavenet-features-private')
Using TensorFlow backend. /home/peter/wavenet-features-private/venv/lib64/python3.6/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.) return torch._C._cuda_getDeviceCount() > 0 /home/peter/wavenet-features-private/venv/lib64/python3.6/site-packages/matplotlib/__init__.py:1405: UserWarning: This call to matplotlib.use() has no effect because the backend has already been chosen; matplotlib.use() must be called *before* pylab, matplotlib.pyplot, or matplotlib.backends is imported for the first time. warnings.warn(_use_error_msg)
base_dir = 'wavenet_vocoder'
filenames = os.listdir(base_dir)
filenames = list(filter(lambda filename : filename.endswith('.pickle'), filenames))
filenames = sorted(filenames, key=lambda filename : int(filename.split('.')[0]), reverse=False)
# paths = [base_dir + '/' + filename for filename in filenames]
def props_to_reg_formula(props):
if 'regularizer' in props.keys():
if props['regularizer'] == 'beta * 16-diversity':
gamma = props['gamma']
mean_term = r'%.2f $\cdot$ mean($\mathbf{x}^2$)' % gamma
beta = props['beta']
div_term = r'$- %.2f \cdot \frac{1}{|\mathbf{x}|}\sum_{i=1}^{n-16} (x_i - x_{i + 16})^2$' % beta
return mean_term + div_term
'''
return (r'$%.2f \cdot \frac{1}{|x|}\sum_{i=1}^{n-16} (x_i - x_{i + 16})^2'
r'+ %.2f \cdot $mean($x^2$)' % (props['beta'], props['gamma']))
'''
return r'none'
def props_to_init_formula(props):
if 'init' in props.keys():
if props['init'] == 'alpha * torch.randn + gamma * mean(tanh**2)':
alpha = props['alpha']
s = r'$\tanh(%.2f \cdot \mathbf{s})$ where' % alpha
s += r' $s_i \sim \mathcal{N}(0,1)$'
return s
return r'zeros'
def display_input(props, x, name):
# print(props)
title = '\n'
title += 'Layer: ' + str(props['conv_id'])
out_type = 'residual' if props['mode'] == 'res' else 'skip'
title += '\nOutput type: ' + out_type
title += '\nChannels: ' + str(props['channel_ids'])
title += '\nRegularizer: ' + props_to_reg_formula(props)
title += '\nInitial ' + r'$\mathbf{x}$ value: ' + props_to_init_formula(props)
# title += '\n' + r'$\min(\mathbf{x})$ = %.2f' % np.min(np.tanh(x))
# title += '\n' + r'$\max(\mathbf{x})$ = %.2f' % np.max(np.tanh(x))
mel = 'zeros' if props['zero_mel'] else 'speech'
title += '\nLocal conditioning input: ' + mel
title += '\n'
fig, axes = plt.subplots(2, figsize=(16,4), dpi=100)
axes[0].set_ylim([-1.1, 1.1])
start = int(len(x) / 2)
end = int(start + SAMPLE_RATE / 20)
if end > len(x):
end = len(x)
for i in range(2):
axes[i].plot(np.tanh(x[start:end]), linewidth=1)
axes[0].set_title(title, fontsize=18, loc='left')
# fig.suptitle(title)
# fig.tight_layout()
# plt.subplots_adjust(top=2)
plt.show()
display(Audio(data=x, rate=SAMPLE_RATE))
for filename in filenames:
path = base_dir + '/' + filename
name = datetime.datetime.fromtimestamp(int(filename.split('.')[0])).strftime('%c')
props, x = pickle.load(open(path, 'rb'))
display_input(props, x, name)